<?php

namespace app\tag\models;

use mini\Model;
use Exception;

class Tag extends Model
{
    /**
     * 根据 id 查询标签内容
     */
    public static function find(int $tag_id)
    {
        $tag = db('tag');

        $fields = 'id, name, intro';
        $data = $tag->where('id = ?', $tag_id)
                    ->first($fields);
        return $data;
    }

    /**
     * 查询全部标签列表
     */
    public static function list(int $page = 10)
    {
        $tag = db('tag');
        $fields = 'id, name, intro';
        $data = $tag->paginate($page)->get($fields);

        return $data;
    }
}